package algorithm.poj.p1000;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.Map;

/**
 * 分析：
 * 
 * 实现：
 * 
 * 经验：
 * 
 * 教训：
 * 努力提高效率！！！
 * 
 * @author wong.tong@gmail.com
 *
 */
public class P1840 {

	public static void main(String[] args) throws Exception {

//		long start = System.currentTimeMillis();
		InputStream input = null;
		if (false) {
			input = System.in;
		} else {
			URL url = P1840.class.getResource("P1840.txt");
			File file = new File(URLDecoder.decode(url.getPath(), "UTF-8"));
			input = new FileInputStream(file);
		}
		
		BufferedReader stdin = new BufferedReader(new InputStreamReader(input));

		String line = stdin.readLine();
		String[] tmp = line.trim().split("\\s+");
		int[] a = new int[5];
		for (int i = 0; i < a.length; i ++) {
			a[i] = Integer.valueOf(tmp[i]);
		}
		System.out.println(solution(a));
//		System.out.println((System.currentTimeMillis()-start) + " ms");
	}

	private static int solution(int[] a) {

		int[] v = new int[100];
		for (int i = 0; i < 50; i ++) {
			v[i] = (i-50)*(i-50)*(i-50);
			v[i+50] = (i+1)*(i+1)*(i+1);
		}
		Map<Integer, Integer> maps = new HashMap<Integer, Integer>();
		int count = 0;
		/*
		 * 这里maps可以保存  a[0]*v[x1] + a[1]*v[x2] + a[2]*v[x3] 或者 -a[3]*v[x4] - a[4]*v[x5]
		 * 两种策略下，使用后者会得到10倍左右的提高。
		 * 这和HashMap的实现方式有关
		 */
		for (int x4 = 0; x4 < 100; x4 ++) {
			for (int x5 = 0; x5 < 100; x5 ++) {
				int t = -a[3]*v[x4] - a[4]*v[x5];
				if (maps.get(t) == null) {
					maps.put(t, 1);
				} else {
					maps.put(t, maps.get(t)+1);
				}
			}
		}
		for (int x1 = 0; x1 < 100; x1 ++) {
			for (int x2 = 0; x2 < 100; x2 ++) {
				for (int x3 = 0; x3 < 100; x3 ++) {
					int t = a[0]*v[x1] + a[1]*v[x2] + a[2]*v[x3];
					Integer c = maps.get(t);
					if (c != null) {
						count += c;
					}
				}
			}
		}
		return count;
	}
}